feat(linter): add unicorn/require-module-attributes rule#17166
feat(linter): add unicorn/require-module-attributes rule#17166camc314 merged 6 commits intooxc-project:mainfrom
unicorn/require-module-attributes rule#17166Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new linter rule unicorn/require-module-attributes that enforces non-empty attribute lists in import/export statements and import() expressions. The rule detects cases where empty attribute objects ({}) or empty with clauses are used, which provide no useful metadata about module loading.
Key changes:
- Implements detection for empty
withclauses in import/export declarations - Implements detection for empty options objects and empty
withproperties in dynamic import expressions - Includes comprehensive test cases covering various edge cases including comments and parenthesized expressions
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/oxc_linter/src/rules/unicorn/require_module_attributes.rs | Main rule implementation with logic to detect empty attribute lists in imports/exports and comprehensive tests |
| crates/oxc_linter/src/rules.rs | Module registration and rule declaration in the all_lint_rules macro |
| crates/oxc_linter/src/generated/rule_runner_impls.rs | Generated rule runner implementation specifying which AST node types trigger the rule |
| crates/oxc_linter/src/snapshots/unicorn_require_module_attributes.snap | Test snapshot showing expected diagnostic output for all failure cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
crates/oxc_linter/src/rules/unicorn/require_module_attributes.rs
Outdated
Show resolved
Hide resolved
CodSpeed Performance ReportMerging #17166 will not alter performanceComparing Summary
Footnotes
|
bffa846 to
9f33910
Compare
this PR adds unicorn/require-module-attributes, issue #684
source doc
source code